/* *
 * @program: VideoDirector
 *
 * @description: ${description}
 *
 * @author: 909845
 *
 * @create: 2018-12-25 16:50
***/

#include "StreamBuffer.h"

CStreamBuffer::CStreamBuffer(const string &strBuf):m_strBuf(strBuf)
{

}

CStreamBuffer::CStreamBuffer(const UInt32 nCapacity)
{
    m_strBuf.reserve(nCapacity);
}

CStreamBuffer::CStreamBuffer(const UInt8 *pBuf, const UInt32 nLen): m_strBuf((const char*)pBuf, nLen)
{

}

CStreamBuffer::~CStreamBuffer()
{

}

void CStreamBuffer::Write(const CStreamBuffer &streamBuffer)
{
    m_strBuf.append(streamBuffer.m_strBuf);
}

void CStreamBuffer::Write(const UInt8 *pBuf, const UInt32 nLen)
{
    m_strBuf.append((const char*)pBuf, nLen);
}

void CStreamBuffer::Write(const string &strBuf)
{
    m_strBuf.append(strBuf);
}

UInt8 *CStreamBuffer::GetData() const
{
    return (UInt8*)m_strBuf.data() + m_uReadLen;
}

UInt32 CStreamBuffer::GetLen() const
{
    return m_strBuf.length() - m_uReadLen;
}

void CStreamBuffer::Clean()
{
    m_uReadLen = 0;
    m_strBuf.clear();
}

void CStreamBuffer::ReadLen(const UInt32 nLen)
{
    Assert(m_strBuf.length() >= (m_uReadLen + nLen));
    m_uReadLen += nLen;
}
